package top.eggcode.setup.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean("rabbit-queue-monitor-metric")
    public Queue createQueueA() {
        return new Queue("monitor-metric", true, false, false);
    }

    @Bean
    DirectExchange directExchange() {
        return new DirectExchange("common", true, false);
    }

    @Bean
    Binding createRuleA(@Qualifier("rabbit-queue-monitor-metric") Queue queue, DirectExchange commonExchange) {
        return BindingBuilder.bind(queue).to(commonExchange).with("monitor-metric-upload");
    }

    @Bean
    Binding createRouteB(@Qualifier("rabbit-queue-monitor-metric") Queue queue, DirectExchange commonExchange) {
        return BindingBuilder.bind(queue).to(commonExchange).with("monitor-metric-alarm");
    }
}
